/* pfs06SpawnPosition.cpp
 *
 * --
 * Copyright (c) 2012, Christophe Huriaux
 * Distributed under the terms of the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * --
 */

#include <packet/pfs06SpawnPosition.h>
#include <wrapper/JavaStreamWrapper.h>

pfs06SpawnPosition::pfs06SpawnPosition()
    : McPacketFromServer(0x06), x(0), y(0), z(0)
{
}

unsigned int pfs06SpawnPosition::length()
{
    return 1 + 4 + 4 + 4;
}

int16_t pfs06SpawnPosition::setField(uint8_t field, void* value)
{

    switch (field)
    {
        case 0:
        default: return 4;
        case 1: x = JavaStreamWrapper::readInt(value); return 4;
        case 2: y = JavaStreamWrapper::readInt(value); return 4;
        case 3: z = JavaStreamWrapper::readInt(value); return -1;
    }
}

int32_t pfs06SpawnPosition::getX()
{
    return x;
}

int32_t pfs06SpawnPosition::getY()
{
    return y;
}

int32_t pfs06SpawnPosition::getZ()
{
    return z;
}


